package com.fanchuan.uzx.ui.utils;


import com.fanchuan.uzx.R;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class DialogUtils {
    public static ProgressDialog getProgressDialog(Context context,String msg) {
         
         ProgressDialog dialog = new ProgressDialog(context);
         dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
         dialog.setMessage(msg);
         dialog.setIndeterminate(false);
         dialog.setCancelable(true);
         return dialog;
    }
    
	public static void noNetworkTip(Context context) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);

		builder.setTitle(context.getString(R.string.app_name));
		builder.setMessage(context.getResources().getString(R.string.tip_no_net));
		builder.setPositiveButton(context.getResources().getString(R.string.tip_ok), new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {

			}
		});
		builder.create().show();
	}

	public static boolean checkNetWork(Context mContext) {
		ConnectivityManager cManager = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo nInfo = cManager.getActiveNetworkInfo();
		if (nInfo == null || !nInfo.isConnected()) {
			return false;
		} 
		return true;
	}
}
